/**
 * Class to create a new interface
 * @version 1.0
 * @param {String} name Name reference for interface
 * @param {Array} methods Array of method names found on the interface.
 */
var $Interface = function (name, methods) {
    if (arguments.length !== 2) {
        throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2.");
    }
    this.name = name;
    this.methods = [];
    for (var i = 0, len = methods.length; i < len; i += 1) {
        if (typeof methods[i] !== 'string') {
            throw new Error("Interface constructor expects method names to be passed in as a string.");
        }
        this.methods.push(methods[i]);
	}
};
/**
 * Check to make sure an object has the expected interface.
 * @param {Function} object Object to check against an interface.
 */
$Interface.ensureImplements = function (object) {
    if (arguments.length < 2) {
        throw new Error("Function Interface.ensureImplements called with " + arguments.length  + "arguments, but expected at least 2.");
    }
    for (var i = 1, len = arguments.length; i < len; i += 1) {
        var interfaces = arguments[i];
        if (interfaces.constructor !== $Interface) {
            throw new Error("Function Interface.ensureImplements expects arguments two and above to be instances of Interface.");
        }
        for (var j = 0, methodsLen = interfaces.methods.length; j < methodsLen; j += 1) {
            var method = interfaces.methods[j];
            if (!object[method] || typeof object[method] !== 'function') {
                throw new Error("Function Interface.ensureImplements: object does not implement the " + interfaces.name + " interface. Method " + method + " was not found.");
            }
        }
    }
	return true;
};
